package designMode.observerPattern;

/**
 * @ClassName CurrentConditionsDisplay
 * @Description
 * @Author LIBOFEI
 * @Date 2020/6/15 09:17
 * @Version 1.0
 **/
public class CurrentConditionsDisplay implements DisplayElement,Observer {

    private float temp;
    private float humidity;
    private Subject weatherData;

    public CurrentConditionsDisplay(Subject weatherData){
        this.weatherData = weatherData;
        weatherData.registerObserver(this);
    }

    @Override
    public void display() {
        System.out.println("Current condition :" + temp + ">>>" + humidity);
    }

    @Override
    public void update(float temp, float humidity, float pressure) {
        this.temp = temp;
        this.humidity = humidity;
        display();
    }
}
